import config from "@/core/config/index.js"
import {$geo} from "@/utils/request/requestConfig.js"


const key = {
	ak:config.get('key')
}

const api = {
	"location":"location/ip",
	"regeo":"reverse_geocoding/v3"
}

/**
 * 调用百度API获得经纬度，属实是脱裤子放屁多此一举

const getLocationCode = async() => {
	const params = {
		coor:"bd09ll",
		...key
	}
	return await $geo.get(api.location,params)
}

export const getUserLocation = async() => {
	const result =  await getLocationCode()
	const {content} = result.data
	const point = content.point
	const location = `${point.y},${point.x}`
	const params = {
		output:"json",
		location,
		...key
	}
	
	return await $geo.get(api.regeo,params);
}
*/

export const getUserLocation = async() => {
	const res = await my.getLocation({ type: 2})
	console.log(res)
	return {
		pointX:res.longitude,
		pointY:res.latitude,
		address:{
			city:res.city,
			district:res.district,
			province:res.province,
			street:res.streetNumber.street,
			number:res.streetNumber.number
		}
	}
}